/*
 * 
 * 
 * 
 */
package com.hboxs.asl.entity;

import com.hboxs.asl.util.DateUtils;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * Entity - 评论
 */
@Entity
@Table(name = "xx_review")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "xx_review_sequence")
public class Review extends BaseEntity {

    private static final long serialVersionUID = 8795901519290584100L;

    /**
     * 访问路径前缀
     */
    private static final String PATH_PREFIX = "/review/content";

    /**
     * 访问路径后缀
     */
    private static final String PATH_SUFFIX = ".htm";

    /**
     * 类型
     */
    public enum Type {

        /**
         * 好评
         */
        positive,

        /**
         * 中评
         */
        moderate,

        /**
         * 差评
         */
        negative
    }

    /**
     * 服务分
     */
    private Float serviceScore;

    /**
     * 方案分
     */
    private Float schemeScore;

    /**
     * 反馈分
     */
    private Float feedbackScore;

    /**
     * 评分
     */
    private Integer score;

    /**
     * 内容
     */
    private String content;

    /**
     * 是否显示
     */
    private Boolean isShow;

    /**
     * IP
     */
    private String ip;

    /**
     * 会员
     */
    private Member member;

    /**
     * 评论的老师
     */
    private Member teacher;

    /**
     * 商品
     */
    private Product product;

    /**
     * 订单项
     */
    private OrderItem orderItem;

    /**
     * 课程
     */
    private Course course;

    /**
     * 获取评分
     *
     * @return 评分
     */
    @NotNull
    @Min(1)
    @Max(5)
    @Column(nullable = false)
    public Integer getScore() {
        return score;
    }

    /**
     * 设置评分
     *
     * @param score 评分
     */
    public void setScore(Integer score) {
        this.score = score;
    }

    /**
     * 获取内容
     *
     * @return 内容
     */
    @NotEmpty
    @Length(max = 200)
    @Column(nullable = false)
    public String getContent() {
        return content;
    }

    /**
     * 设置内容
     *
     * @param content 内容
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * 获取是否显示
     *
     * @return 是否显示
     */
    @Column(nullable = false)
    public Boolean getIsShow() {
        return isShow;
    }

    /**
     * 设置是否显示
     *
     * @param isShow 是否显示
     */
    public void setIsShow(Boolean isShow) {
        this.isShow = isShow;
    }

    /**
     * 获取IP
     *
     * @return IP
     */
    @Column(nullable = false, updatable = false)
    public String getIp() {
        return ip;
    }

    /**
     * 设置IP
     *
     * @param ip IP
     */
    public void setIp(String ip) {
        this.ip = ip;
    }

    /**
     * 获取会员
     *
     * @return 会员
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(updatable = false)
    public Member getMember() {
        return member;
    }

    /**
     * 设置会员
     *
     * @param member 会员
     */
    public void setMember(Member member) {
        this.member = member;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(updatable = false)
    public Member getTeacher() {
        return teacher;
    }

    public void setTeacher(Member teacher) {
        this.teacher = teacher;
    }

    /**
     * 获取商品
     *
     * @return 商品
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(nullable = false, updatable = false)
    public Product getProduct() {
        return product;
    }

    /**
     * 设置商品
     *
     * @param product 商品
     */
    public void setProduct(Product product) {
        this.product = product;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(nullable = false)
    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    /**
     * 获取订单项
     *
     * @return 订单项
     */
    @ManyToOne(fetch = FetchType.LAZY)
    public OrderItem getOrderItem() {
        return orderItem;
    }

    /**
     * 设置订单项
     *
     * @param orderItem 订单项
     */
    public void setOrderItem(OrderItem orderItem) {
        this.orderItem = orderItem;
    }

    public Float getServiceScore() {
        return serviceScore;
    }

    public void setServiceScore(Float serviceScore) {
        this.serviceScore = serviceScore;
    }

    public Float getSchemeScore() {
        return schemeScore;
    }

    public void setSchemeScore(Float schemeScore) {
        this.schemeScore = schemeScore;
    }

    public Float getFeedbackScore() {
        return feedbackScore;
    }

    public void setFeedbackScore(Float feedbackScore) {
        this.feedbackScore = feedbackScore;
    }

    @Transient
    public String getCreateDateF(){
        return DateUtils.dateToStr(super.getCreateDate());
    }
}